package com.kandinfo.isbnmanage.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.kandinfo.base.common.repository.BaseRepository;
import com.kandinfo.isbnmanage.domian.IsbnPage;

public interface IsbnPageRepository extends BaseRepository<IsbnPage, Long> {

	@Query(value="select ip.* from isbn_page ip where ip.isbn_information_id = ?1" ,nativeQuery=true)
	List<IsbnPage> findByIsbnInformationId(Long isbnInformationId);
	
	@Query(value="select * from isbn_page where barcode = ?1" ,nativeQuery=true)
	List<IsbnPage> findByBarcode(String barcode);
	
	@Query(value="select * from isbn_page where isbn_information_id = ?1" ,nativeQuery=true)
	List<IsbnPage> findPagesByInforId(Long isbnInformationId);
	
	@Query(value="SELECT * FROM isbn_page where isbn_information_id = ?1 and status = ?2" ,nativeQuery=true)
	List<IsbnPage> findByInformationId(Long informationId, String status);
	
	@Modifying
	@Query( value = "update isbn_page set status = '0'  where isbn_information_id = ?1 and file_name = ?2 " , nativeQuery = true )
	void deletePage(Long isbnInformationId, String fileName);
}
